<!doctype html>
<html lang="zh-CN" th:replace="admin-layout :: layout(~{::title}, ~{}, ~{::script}, ~{::body}, 'paper-list')"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <title th:text="${data}?'修改试卷':_">添加试卷</title>
    <script th:inline="javascript">
        $("#submitBtn").click(function () {
            var name = $("input[name='name']").val();
            if (!name) {
                msgAlert("请输入试卷名称")
                return;
            }
            var time = $("input[name='time']").val();
            if (!time) {
                msgAlert("请输入答题时间")
                return;
            }
            ajaxJson("/admin/paper/ajax/save", $("#form").serialize(), function (res) {
                if (res.status) {
                    location.href = "/admin/paper/list";
                }
            })
        })
    </script>
</head>
<body>
<!--<ol class="breadcrumb">
    <li><a th:href="@{/admin/paper/list}">试卷列表</a></li>
    <li class="active" th:text="${data}?'修改试卷':_">添加试卷</li>
</ol>-->
<form class="form-horizontal" id="form">
    <input type="hidden" name="id" th:if="${data}" th:value="${data.id}">
    <div class="form-group">
        <label class="col-sm-2 col-md-2 col-lg-3 control-label"><span class="text-danger">*&nbsp;</span>试卷名称</label>
        <div class="col-sm-8 col-md-8 col-lg-6">
            <input type="text" class="form-control" id="name" placeholder="试卷名称" name="name"
                   th:value="${data}?${data.name}">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 col-md-2 col-lg-3 control-label"><span class="text-danger">*&nbsp;</span>答卷时间</label>
        <div class="col-sm-8 col-md-8 col-lg-6">
            <div class="input-group">
                <input type="text" class="form-control" id="time" placeholder="答卷时间（分钟）" name="time"
                       th:value="${data}?${data.time}">
                <span class="input-group-addon">分钟</span>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 col-md-2 col-lg-3 control-label"><span class="text-danger">*&nbsp;</span>试卷类型</label>
        <div class="col-sm-8 col-md-8 col-lg-6">
            <select class="form-control" name="type" id="type" th:disabled="${data}!=null">
                <option value="0" th:selected="${data}?${data.type}==0">随机出题</option>
                <option value="1" th:selected="${data}?${data.type}==1">固定出题</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-md-offset-2 col-lg-offset-3 col-sm-8 col-md-8 col-lg-6">
            <button type="button" class="btn btn-primary" id="submitBtn">提交</button>
            <button type="button" class="btn btn-warning backBtn">返回</button>
        </div>
    </div>
</form>
</body>
</html>